package com.ruoyi.dictionaries.service;

import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.dictionaries.domain.vo.ApprovalClassAdjustmentvVo;
import com.ruoyi.dictionaries.domain.vo.StatusChangeVo;
import com.ruoyi.trainingManagement.domain.CourseAdjustmentRecord;
import com.ruoyi.trainingManagement.mapper.CourseAdjustmentRecordMapper;
import org.openoa.base.interf.ActivitiService;
import org.openoa.base.interf.ActivitiServiceAnno;
import org.openoa.base.interf.FormOperationAdaptor;
import org.openoa.base.util.SecurityUtils;
import org.openoa.base.vo.BpmnStartConditionsVo;
import org.openoa.base.vo.BusinessDataVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@ActivitiServiceAnno(svcName = "Approval_Class_adjustment",desc = "调停课审批")
@Service("Approval_Class_adjustment")
public class TTKApprovalClassAdjustment implements FormOperationAdaptor<ApprovalClassAdjustmentvVo>, ActivitiService {
    @Autowired
    private CourseAdjustmentRecordMapper courseAdjustmentRecordMapper;
    @Override
    public BpmnStartConditionsVo previewSetCondition(ApprovalClassAdjustmentvVo vo) {
        String userId = vo.getStartUserId();
        return BpmnStartConditionsVo.builder()
                .startUserId(userId)
                .build();
    }

    @Override
    public void initData(ApprovalClassAdjustmentvVo vo) {
        // 初始化数据，可设置默认值
        vo.setApplyDate(String.valueOf(new Date()));
        vo.setMaterialsStatus("待审核");
        vo.setReviewer1Result("待审核");
        vo.setReviewer2Result("待审核");
        vo.setReviewer3Result("待审核");
    }

    @Override
    public BpmnStartConditionsVo launchParameters(ApprovalClassAdjustmentvVo vo) {
        String userId = vo.getStartUserId();
        return BpmnStartConditionsVo.builder()
                .startUserId(userId)
                .build();
    }

    @Override
    public void queryData(ApprovalClassAdjustmentvVo vo) {
        CourseAdjustmentRecord approvalClassAdjustmentvVo = courseAdjustmentRecordMapper.selectCourseAdjustmentRecordById(vo.getBusinessId());
        if (approvalClassAdjustmentvVo != null) {
            BeanUtils.copyProperties(approvalClassAdjustmentvVo, vo);
        }
    }

    @Override
    public void submitData(ApprovalClassAdjustmentvVo vo) {
        CourseAdjustmentRecord approvalClassAdjustmentvVo =new CourseAdjustmentRecord();
        BeanUtils.copyProperties(approvalClassAdjustmentvVo, vo);
        approvalClassAdjustmentvVo.setId(IdUtils.fastSimpleUUID());
        approvalClassAdjustmentvVo.setCreateTime(new Date());
        approvalClassAdjustmentvVo.setCreateBy(SecurityUtils.getLogInEmpNameSafe());


    }

    @Override
    public void consentData(ApprovalClassAdjustmentvVo vo) {

    }

    @Override
    public void backToModifyData(ApprovalClassAdjustmentvVo vo) {

    }

    @Override
    public void cancellationData(ApprovalClassAdjustmentvVo businessDataVo) {

    }

    @Override
    public void finishData(BusinessDataVo vo) {

    }
}
